/**
 * @author chenz
 */

/*
 * Good Links For What I Want...
 * http://developer.mozilla.org/en/docs/Code_snippets:On_page_load
 * http://developer.mozilla.org/en/docs/Code_snippets:Progress_Listeners
 * http://developer.mozilla.org/en/docs/Storage
 */

var websitenotes = {resourcePrefix:"chrome://websitenotes/content/"};

//Ugly workaround for tracking if all windows are loading or loaded.
websitenotes.tabwindows = new Array();

//Event Listener Registrations
window.addEventListener("mousemove", function(e) { websitenotes.websiteMouseTracker(e); }, false);
window.addEventListener("load", function() { gBrowser.addProgressListener(tabListener,
  Components.interfaces.nsIWebProgress.NOTIFY_STATE_DOCUMENT); }, false);
window.addEventListener("keypress", function(e) { websitenotes.createWebsiteNote(e); }, false);

//Opening Local Website Notes Database
var file = Components.classes["@mozilla.org/file/directory_service;1"]
                     .getService(Components.interfaces.nsIProperties)
                     .get("TmpD", Components.interfaces.nsIFile);
file.append("local.websitenotes.sqlite");

var storageService = Components.classes["@mozilla.org/storage/service;1"]
                        .getService(Components.interfaces.mozIStorageService);
var mDBConn = storageService.openDatabase(file);

websitenotes.notesHidden = new Boolean(false);